<HTML>
<HEAD>
<TITLE>[Chapter 19] Rectangle</TITLE>
<META NAME="author" CONTENT="John Zukowski">
<META NAME="date" CONTENT="Thu Jul 31 15:15:39 1997">
<META NAME="form" CONTENT="html">
<META NAME="metadata" CONTENT="dublincore.0.1">
<META NAME="objecttype" CONTENT="book part">
<META NAME="otheragent" CONTENT="gmat dbtohtml">
<META NAME="publisher" CONTENT="O'Reilly &amp; Associates, Inc.">
<META NAME="source" CONTENT="SGML">
<META NAME="subject" CONTENT="Java AWT">
<META NAME="title" CONTENT="Java AWT">
<META HTTP-EQUIV="Content-Script-Type" CONTENT="text/javascript">
</HEAD>
<body vlink="#551a8b" alink="#ff0000" text="#000000" bgcolor="#FFFFFF" link="#0000ee">

<DIV CLASS=htmlnav>
<H1><a href='index.htm'><IMG SRC="gifs/smbanner.gif"
     ALT="Java AWT" border=0></a></H1>
<table width=515 border=0 cellpadding=0 cellspacing=0>
<tr>
<td width=172 align=left valign=top><A HREF="ch19_51.htm"><IMG SRC="gifs/txtpreva.gif" ALT="Previous" border=0></A></td>
<td width=171 align=center valign=top><B><FONT FACE="ARIEL,HELVETICA,HELV,SANSERIF" SIZE="-1">Chapter 19<br>java.awt Reference</FONT></B></TD>
<td width=172 align=right valign=top><A HREF="ch19_53.htm"><IMG SRC="gifs/txtnexta.gif" ALT="Next" border=0></A></td>
</tr>
</table>

&nbsp;
<hr align=left width=515>
</DIV>
<DIV CLASS=refnamediv>
<H1>Rectangle</H1>

<H2>Name</H2>

Rectangle

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="ch19-REFSECT1-AUTOID.52"></A></h2>
</DIV>


<p>
<img align=middle src="./figs/rectang.gif" alt="[Graphic: Figure from the text]" width=502 height=77 border=0>

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="JAWT-CH-19-REF-RECTANGLE-SECT-1">Description</A></h2>

<P CLASS=para>
The <tt CLASS=literal>Rectangle</tt> class represents 
a rectangle by combining its origin (a pair of x and y coordinates) with 
its size (a width and a height). 

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="JAWT-CH-19-REF-RECTANGLE-SECT-2">Class Definition</A></h2>

<DIV CLASS=screen>
<P>
<PRE>
public class java.awt.Rectangle
    extends java.lang.Object
    implements java.awt.Shape, java.io.Serializable {
  
  // Variables
  pubic int height;
  public int width;
  public int x;
  public int y;
  
  // Constructors
  public Rectangle();
  public Rectangle (int width, int height);
  public Rectangle (int x, int y, int width, int height);
  public Rectangle (Dimension d);
  public Rectangle (Point p);
  public Rectangle (Point p, Dimension d);
  public Rectangle (Rectangle r); <img src="gifs/bstar.gif" alt="(New)" border=0>
  
  // Instance Methods
  public void add (int newX, int newY);
  public void add (Point p);
  public void add (Rectangle r);
  public boolean contains (int x, int y); <img src="gifs/bstar.gif" alt="(New)" border=0>
  public boolean contains (Point p); <img src="gifs/bstar.gif" alt="(New)" border=0>
  public boolean equals (Object object);
  public Rectangle getBounds(); <img src="gifs/bstar.gif" alt="(New)" border=0>
  public Point getLocation(); <img src="gifs/bstar.gif" alt="(New)" border=0>
  public Dimension getSize(); <img src="gifs/bstar.gif" alt="(New)" border=0>
  public void grow (int horizontal, int vertical);
  public int hashCode();
  public boolean inside (int x, int y); <img src="gifs/wstar.gif" alt="(Deprecated)" border=0>
  public Rectangle intersection (Rectangle r);
  public boolean intersects (Rectangle r);
  public boolean isEmpty();
  public void move (int x, int y); <img src="gifs/wstar.gif" alt="(Deprecated)" border=0>
  public void reshape (int x, int y, int width, int height); <img src="gifs/wstar.gif" alt="(Deprecated)" border=0>
  public void resize (int width, int height); <img src="gifs/wstar.gif" alt="(Deprecated)" border=0>
  public void setBounds (Rectangle r); <img src="gifs/bstar.gif" alt="(New)" border=0>
  public void setBounds (int x, int y, int width, int height); <img src="gifs/bstar.gif" alt="(New)" border=0>
  public void setLocation (int x, int y); <img src="gifs/bstar.gif" alt="(New)" border=0>
  public void setLocation (Point p); <img src="gifs/bstar.gif" alt="(New)" border=0>
  public void setSize (int width, int height); <img src="gifs/bstar.gif" alt="(New)" border=0>
  public void setSize (Dimension d); <img src="gifs/bstar.gif" alt="(New)" border=0>
  public String toString();
  public void translate (int x, int y);
  public Rectangle union (Rectangle r);
}
</PRE>
</DIV>

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="JAWT-CH-19-REF-RECTANGLE-SECT-3">Variables</A></h2>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="JAWT-CH-19-REF-RECTANGLE-SECT-3.1">height</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="JAWT-CH-19-REF-RECTANGLE-SECT-3.1.1">public int height</A></h4>

<P CLASS=para>
The height of the <tt CLASS=literal>Rectangle</tt>. 

</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="JAWT-CH-19-REF-RECTANGLE-SECT-3.2">width</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="JAWT-CH-19-REF-RECTANGLE-SECT-3.2.1">public int width</A></h4>

<P CLASS=para>
The width of the <tt CLASS=literal>Rectangle</tt>. 

</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="JAWT-CH-19-REF-RECTANGLE-SECT-3.3">x</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="JAWT-CH-19-REF-RECTANGLE-SECT-3.3.1">public int x</A></h4>

<P CLASS=para>
The x coordinate of the <tt CLASS=literal>Rectangle</tt>'s 
upper left corner (its origin). 

</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="JAWT-CH-19-REF-RECTANGLE-SECT-3.4">y</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="JAWT-CH-19-REF-RECTANGLE-SECT-3.4.1">public int y</A></h4>

<P CLASS=para>
The y coordinate of the <tt CLASS=literal>Rectangle</tt>'s 
upper left corner (its origin). 

</DIV>

</DIV>

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="JAWT-CH-19-REF-RECTANGLE-SECT-4">Constructors</A></h2>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="JAWT-CH-19-REF-RECTANGLE-SECT-4.1">Rectangle</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="JAWT-CH-19-REF-RECTANGLE-SECT-4.1.1">public Rectangle()</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
Constructs an empty <tt CLASS=literal>Rectangle</tt> 
object with an origin of (0, 0) and dimensions of 0 x 0. </DL>
</DIV>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="JAWT-CH-19-REF-RECTANGLE-SECT-4.1.2">public Rectangle (int width, int height)</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><I CLASS=emphasis>width</I><br>
<DD>

<P CLASS=para>
width of <tt CLASS=literal>Rectangle</tt> 

<p>
<DT CLASS=varlistentry><I CLASS=emphasis>height</I><br>
<DD>

<P CLASS=para>
height of <tt CLASS=literal>Rectangle</tt> </DL>
<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
Constructs a <tt CLASS=literal>Rectangle</tt> object 
with an origin of (0, 0) and dimensions of <tt CLASS=literal>width</tt> 
x <tt CLASS=literal>height</tt>. </DL>
</DIV>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="JAWT-CH-19-REF-RECTANGLE-SECT-4.1.3">public Rectangle (int x, int y, int width, int height)</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><I CLASS=emphasis>x</I><br>
<DD>

<P CLASS=para>
x coordinate of the <tt CLASS=literal>Rectangle</tt>'s 
origin 

<p>
<DT CLASS=varlistentry><I CLASS=emphasis>y</I><br>
<DD>

<P CLASS=para>
y coordinate of the <tt CLASS=literal>Rectangle</tt>'s 
origin 

<p>
<DT CLASS=varlistentry><I CLASS=emphasis>width</I><br>
<DD>

<P CLASS=para>
width of <tt CLASS=literal>Rectangle</tt> 

<p>
<DT CLASS=varlistentry><I CLASS=emphasis>height</I><br>
<DD>

<P CLASS=para>
height of <tt CLASS=literal>Rectangle</tt> </DL>
<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
Constructs a <tt CLASS=literal>Rectangle</tt> object 
with an origin of (<tt CLASS=literal>x</tt>, <tt CLASS=literal>y</tt>) 
and dimensions of <tt CLASS=literal>width</tt> x <tt CLASS=literal>height</tt>. </DL>
</DIV>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="JAWT-CH-19-REF-RECTANGLE-SECT-4.1.4">public Rectangle (Dimension d)</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><I CLASS=emphasis>d</I><br>
<DD>

<P CLASS=para>
dimensions of <tt CLASS=literal>Rectangle</tt> </DL>
<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
Constructs a <tt CLASS=literal>Rectangle</tt> object 
with an origin of (0, 0) and dimensions of <tt CLASS=literal>d.width</tt> 
x <tt CLASS=literal>d.height</tt>. </DL>
</DIV>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="JAWT-CH-19-REF-RECTANGLE-SECT-4.1.5">public Rectangle (Point p)</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><I CLASS=emphasis>p</I><br>
<DD>

<P CLASS=para>
origin of <tt CLASS=literal>Rectangle</tt> </DL>
<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
Constructs an empty <tt CLASS=literal>Rectangle</tt> 
object with an origin of (<tt CLASS=literal>p.x</tt>, 
<tt CLASS=literal>p.y</tt>) and dimensions of 0 x 
0. </DL>
</DIV>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="JAWT-CH-19-REF-RECTANGLE-SECT-4.1.6">public Rectangle (Point p, Dimension d)</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><I CLASS=emphasis>p</I><br>
<DD>

<P CLASS=para>
origin of <tt CLASS=literal>Rectangle</tt> 

<p>
<DT CLASS=varlistentry><I CLASS=emphasis>d</I><br>
<DD>

<P CLASS=para>
dimensions of <tt CLASS=literal>Rectangle</tt> </DL>
<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
Constructs a <tt CLASS=literal>Rectangle</tt> object 
with an origin of (<tt CLASS=literal>p.x</tt>, <tt CLASS=literal>p.y</tt>) 
and dimensions of <tt CLASS=literal>d.width</tt> x 
<tt CLASS=literal>d.height</tt>. </DL>
</DIV>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="JAWT-CH-19-REF-RECTANGLE-SECT-4.1.7">public Rectangle (Rectangle r) <img src="gifs/bstar.gif" alt="(New)" border=0></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><I CLASS=emphasis>r</I><br>
<DD>

<P CLASS=para>
original <tt CLASS=literal>Rectangle</tt> </DL>
<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
Constructs copy of the given <tt CLASS=literal>Rectangle</tt>. </DL>
</DIV>

</DIV>

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="JAWT-CH-19-REF-RECTANGLE-SECT-5">Instance Methods</A></h2>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="JAWT-CH-19-REF-RECTANGLE-SECT-5.1">add</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="JAWT-CH-19-REF-RECTANGLE-SECT-5.1.1">public void add (int newX, int newY)</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><I CLASS=emphasis>newX</I><br>
<DD>

<P CLASS=para>
The x-coordinate of 
a point to incorporate within the <tt CLASS=literal>Rectangle</tt>. 

<p>
<DT CLASS=varlistentry><I CLASS=emphasis>newY</I><br>
<DD>

<P CLASS=para>
The y-coordinate of 
a point to incorporate within the <tt CLASS=literal>Rectangle</tt>. </DL>
<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
Extends the <tt CLASS=literal>Rectangle</tt> so that 
the point (<tt CLASS=literal>newX</tt>, <tt CLASS=literal>newY</tt>) 
is within it. </DL>
</DIV>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="JAWT-CH-19-REF-RECTANGLE-SECT-5.1.2">public void add (Point p)</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><I CLASS=emphasis>p</I><br>
<DD>

<P CLASS=para>
The new <tt CLASS=literal>Point</tt> 
to add to the <tt CLASS=literal>Rectangle</tt>. </DL>
<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
Extends the <tt CLASS=literal>Rectangle</tt> so that 
the point <tt CLASS=literal>p</tt> is within it. </DL>
</DIV>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="JAWT-CH-19-REF-RECTANGLE-SECT-5.1.3">public void add (Rectangle r)</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><I CLASS=emphasis>r</I><br>
<DD>

<P CLASS=para>
The <tt CLASS=literal>Rectangle</tt> 
being added to the current <tt CLASS=literal>Rectangle</tt>. </DL>
<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
Extends the <tt CLASS=literal>Rectangle</tt> to include 
the <tt CLASS=literal>Rectangle</tt> <tt CLASS=literal>r</tt>. </DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="JAWT-CH-19-REF-RECTANGLE-SECT-5.2">contains</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="JAWT-CH-19-REF-RECTANGLE-SECT-5.2.1">public boolean contains (int x, int y) <img src="gifs/bstar.gif" alt="(New)" border=0></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><I CLASS=emphasis>x</I><br>
<DD>

<P CLASS=para>
The x coordinate to test. 

<p>
<DT CLASS=varlistentry><I CLASS=emphasis>y</I><br>
<DD>

<P CLASS=para>
The y coordinate to test. </DL>
<p>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>true</tt> if the <tt CLASS=literal>Rectangle</tt> 
contains the point; <tt CLASS=literal>false</tt> otherwise. </DL>
</DIV>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="JAWT-CH-19-REF-RECTANGLE-SECT-5.2.2">public boolean contains (Point p) <img src="gifs/bstar.gif" alt="(New)" border=0></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><I CLASS=emphasis>p</I><br>
<DD>

<P CLASS=para>
The point to be tested. </DL>
<p>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>true</tt> if the <tt CLASS=literal>Rectangle</tt> 
contains the point; <tt CLASS=literal>false</tt> otherwise. </DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="JAWT-CH-19-REF-RECTANGLE-SECT-5.3">equals</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="JAWT-CH-19-REF-RECTANGLE-SECT-5.3.1">public boolean equals (Object object)</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><I CLASS=emphasis>object</I><br>
<DD>

<P CLASS=para>
The object to compare. </DL>
<p>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>true</tt> if both <tt CLASS=literal>Rectangle</tt>s 
have the same origin, width, and height; <tt CLASS=literal>false</tt> 
otherwise. 

<p>
<DT CLASS=varlistentry>Overrides <br>
<DD>

<P CLASS=para>
<tt CLASS=literal>Object.equals(Object)</tt> 

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
Compares two different <tt CLASS=literal>Rectangle</tt> 
instances for equivalence. </DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="JAWT-CH-19-REF-RECTANGLE-SECT-5.4">getBounds</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="JAWT-CH-19-REF-RECTANGLE-SECT-5.4.1">public Rectangle getBounds() <img src="gifs/bstar.gif" alt="(New)" border=0></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Implements <br>
<DD>

<P CLASS=para>
<tt CLASS=literal>Shape.getBounds()</tt> 

<p>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
Bounding <tt CLASS=literal>Rectangle</tt>. </DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="JAWT-CH-19-REF-RECTANGLE-SECT-5.5">getLocation</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="JAWT-CH-19-REF-RECTANGLE-SECT-5.5.1">public Point getLocation() <img src="gifs/bstar.gif" alt="(New)" border=0></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
Position of the rectangle. 

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
Gets the current position of this <tt CLASS=literal>Rectangle</tt>. </DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="JAWT-CH-19-REF-RECTANGLE-SECT-5.6">getSize</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="JAWT-CH-19-REF-RECTANGLE-SECT-5.6.1">public Dimension getSize() <img src="gifs/bstar.gif" alt="(New)" border=0></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
Dimensions of the rectangle. 

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
Gets width and height of the rectangle. </DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="JAWT-CH-19-REF-RECTANGLE-SECT-5.7">grow</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="JAWT-CH-19-REF-RECTANGLE-SECT-5.7.1">public void grow (int horizontal, int vertical)</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><I CLASS=emphasis>horizontal</I><br>
<DD>

<P CLASS=para>
Amount to extend 
<tt CLASS=literal>Rectangle</tt> in horizontal direction 
on both the left and right sides. 

<p>
<DT CLASS=varlistentry><I CLASS=emphasis>vertical</I><br>
<DD>

<P CLASS=para>
Amount to extend 
<tt CLASS=literal>Rectangle</tt> in vertical direction 
on both the top and the bottom. </DL>
<p>
<DT CLASS=varlistentry>Description <br>
<DD>

<P CLASS=para>
Increases the rectangle's dimensions. </DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="JAWT-CH-19-REF-RECTANGLE-SECT-5.8">hashCode</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="JAWT-CH-19-REF-RECTANGLE-SECT-5.8.1">public int hashCode()</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
A hashcode to use when using the <tt CLASS=literal>Rectangle</tt> 
as a key in a <tt CLASS=literal>Hashtable</tt>. 

<p>
<DT CLASS=varlistentry>Overrides <br>
<DD>

<P CLASS=para>
<tt CLASS=literal>Object.hashCode()</tt> 

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
Generates a hashcode for the <tt CLASS=literal>Rectangle</tt>. </DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="JAWT-CH-19-REF-RECTANGLE-SECT-5.9">inside</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="JAWT-CH-19-REF-RECTANGLE-SECT-5.9.1">public boolean inside (int x, int y) <img src="gifs/wstar.gif" alt="(Deprecated)" border=0></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters <br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><I CLASS=emphasis>x</I><br>
<DD>

<P CLASS=para>
The x coordinate to check. 

<p>
<DT CLASS=varlistentry><I CLASS=emphasis>y</I><br>
<DD>

<P CLASS=para>
The y coordinate to check. </DL>
<p>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>true</tt> if (<tt CLASS=literal>x</tt>, 
<tt CLASS=literal>y</tt>) falls within the <tt CLASS=literal>Rectangle</tt>, 
<tt CLASS=literal>false</tt> otherwise. 

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
Checks to see if the point (<tt CLASS=literal>x</tt>, 
<tt CLASS=literal>y</tt>) is within the <tt CLASS=literal>Rectangle</tt>. 
Replaced by <tt CLASS=literal>contains(int, int)</tt>. </DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="JAWT-CH-19-REF-RECTANGLE-SECT-5.10">intersection</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="JAWT-CH-19-REF-RECTANGLE-SECT-5.10.1">public Rectangle intersection (Rectangle r)</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters <br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><I CLASS=emphasis>r</I><br>
<DD>

<P CLASS=para>
<tt CLASS=literal>Rectangle</tt> 
to add to the current <tt CLASS=literal>Rectangle</tt>. </DL>
<p>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
A new <tt CLASS=literal>Rectangle</tt> consisting 
of all points in both the current <tt CLASS=literal>Rectangle</tt> 
and <tt CLASS=literal>r</tt>. 

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
Generates a new <tt CLASS=literal>Rectangle</tt> that 
is the intersection of <tt CLASS=literal>r</tt> and 
the current <tt CLASS=literal>Rectangle</tt>. </DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="JAWT-CH-19-REF-RECTANGLE-SECT-5.11">intersects</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="JAWT-CH-19-REF-RECTANGLE-SECT-5.11.1">public boolean intersects (Rectangle r)</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters <br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><I CLASS=emphasis>r</I><br>
<DD>

<P CLASS=para>
<tt CLASS=literal>Rectangle</tt> 
to check. </DL>
<p>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>true</tt> if any points in <tt CLASS=literal>r</tt>
are also in the current <tt CLASS=literal>Rectangle</tt>, 
<tt CLASS=literal>false</tt> otherwise. 

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
Checks to see if <tt CLASS=literal>r</tt> crosses 
the <tt CLASS=literal>Rectangle</tt>. </DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="JAWT-CH-19-REF-RECTANGLE-SECT-5.12">isEmpty</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="JAWT-CH-19-REF-RECTANGLE-SECT-5.12.1">public boolean isEmpty()</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>true</tt> if the <tt CLASS=literal>Rectangle</tt> 
is empty, <tt CLASS=literal>false</tt> otherwise. 

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
Determines if the rectangle is dimensionless (i.e., width or height are 
less than or equal to 0). </DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="JAWT-CH-19-REF-RECTANGLE-SECT-5.13">move</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="JAWT-CH-19-REF-RECTANGLE-SECT-5.13.1">public void move (int x, int y) <img src="gifs/wstar.gif" alt="(Deprecated)" border=0></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters <br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><I CLASS=emphasis>x</I><br>
<DD>

<P CLASS=para>
The new x coordinate of 
the <tt CLASS=literal>Rectangle</tt>'s upper 
left corner. 

<p>
<DT CLASS=varlistentry><I CLASS=emphasis>y</I><br>
<DD>

<P CLASS=para>
The new y coordinate of 
the <tt CLASS=literal>Rectangle</tt>'s upper 
left corner. </DL>
<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
Changes the <tt CLASS=literal>Rectangle</tt>'s 
origin to (<tt CLASS=literal>x</tt>, <tt CLASS=literal>y</tt>). 
Replaced by <tt CLASS=literal>setLocation(int, int)</tt>. </DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="JAWT-CH-19-REF-RECTANGLE-SECT-5.14">reshape</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="JAWT-CH-19-REF-RECTANGLE-SECT-5.14.1">public void reshape (int x, int y, int width, int height) <img src="gifs/wstar.gif" alt="(Deprecated)" border=0></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters <br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><I CLASS=emphasis>x</I><br>
<DD>

<P CLASS=para>
The new x coordinate of 
the <tt CLASS=literal>Rectangle</tt>'s upper 
left corner. 

<p>
<DT CLASS=varlistentry><I CLASS=emphasis>y</I><br>
<DD>

<P CLASS=para>
The new y coordinate of 
the <tt CLASS=literal>Rectangle</tt>'s upper 
left corner. 

<p>
<DT CLASS=varlistentry><I CLASS=emphasis>width</I><br>
<DD>

<P CLASS=para>
The new width. 

<p>
<DT CLASS=varlistentry><I CLASS=emphasis>height</I><br>
<DD>

<P CLASS=para>
The new height. </DL>
<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
Changes <tt CLASS=literal>Rectangle</tt>'s origin 
and dimensions. Replaced by <tt CLASS=literal>setBounds(int, int, int, 
int)</tt>. </DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="JAWT-CH-19-REF-RECTANGLE-SECT-5.15">resize</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="JAWT-CH-19-REF-RECTANGLE-SECT-5.15.1">public void resize (int width, int height) <img src="gifs/wstar.gif" alt="(Deprecated)" border=0></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters <br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><I CLASS=emphasis>width</I><br>
<DD>

<P CLASS=para>
The new width. 

<p>
<DT CLASS=varlistentry><I CLASS=emphasis>height</I><br>
<DD>

<P CLASS=para>
The new height. </DL>
<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
Changes <tt CLASS=literal>Rectangle</tt>'s dimensions. 
Replaced by <tt CLASS=literal>setSize(int, int)</tt>. </DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="JAWT-CH-19-REF-RECTANGLE-SECT-5.16">setBounds</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="JAWT-CH-19-REF-RECTANGLE-SECT-5.16.1">public void setBounds (Rectangle r) <img src="gifs/bstar.gif" alt="(New)" border=0></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters <br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><I CLASS=emphasis>r</I><br>
<DD>

<P CLASS=para>
A <tt CLASS=literal>Rectangle</tt> 
describing the new bounds. </DL>
<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
Changes <tt CLASS=literal>Rectangle</tt>'s location 
and size. </DL>
</DIV>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="JAWT-CH-19-REF-RECTANGLE-SECT-5.16.2">public void setBounds (int x, int y, int width, int height) [New in 1.1]</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters <br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><I CLASS=emphasis>x</I><br>
<DD>

<P CLASS=para>
The new x coordinate of 
the <tt CLASS=literal>Rectangle</tt>'s upper 
left corner. 

<p>
<DT CLASS=varlistentry><I CLASS=emphasis>y</I><br>
<DD>

<P CLASS=para>
The new y coordinate of 
the <tt CLASS=literal>Rectangle</tt>'s upper 
left corner. 

<p>
<DT CLASS=varlistentry><I CLASS=emphasis>width</I><br>
<DD>

<P CLASS=para>
The new width. 

<p>
<DT CLASS=varlistentry><I CLASS=emphasis>height</I><br>
<DD>

<P CLASS=para>
The new height. </DL>
<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
Changes <tt CLASS=literal>Rectangle</tt>'s location 
and size. </DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="JAWT-CH-19-REF-RECTANGLE-SECT-5.17">setLocation</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="JAWT-CH-19-REF-RECTANGLE-SECT-5.17.1">public void setLocation (int x, int y) <img src="gifs/bstar.gif" alt="(New)" border=0></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters <br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><I CLASS=emphasis>x</I><br>
<DD>

<P CLASS=para>
New horizontal position. 

<p>
<DT CLASS=varlistentry><I CLASS=emphasis>y</I><br>
<DD>

<P CLASS=para>
New vertical position. </DL>
<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
Relocates the rectangle. </DL>
</DIV>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="JAWT-CH-19-REF-RECTANGLE-SECT-5.17.2">public void setLocation (Point p) <img src="gifs/bstar.gif" alt="(New)" border=0></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters <br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><I CLASS=emphasis>p</I><br>
<DD>

<P CLASS=para>
New position for component. </DL>
<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
Relocates the rectangle. </DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="JAWT-CH-19-REF-RECTANGLE-SECT-5.18">setSize</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="JAWT-CH-19-REF-RECTANGLE-SECT-5.18.1">public void setSize (int width, int height) <img src="gifs/bstar.gif" alt="(New)" border=0></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters <br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><I CLASS=emphasis>width</I><br>
<DD>

<P CLASS=para>
New width. 

<p>
<DT CLASS=varlistentry><I CLASS=emphasis>height</I><br>
<DD>

<P CLASS=para>
New height. </DL>
<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
Resizes the rectangle. </DL>
</DIV>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="JAWT-CH-19-REF-RECTANGLE-SECT-5.18.2">public void setSize (Dimension d) <img src="gifs/bstar.gif" alt="(New)" border=0></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters <br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><I CLASS=emphasis>d</I><br>
<DD>

<P CLASS=para>
New dimensions. </DL>
<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
Resizes the rectangle. </DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="JAWT-CH-19-REF-RECTANGLE-SECT-5.19">toString</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="JAWT-CH-19-REF-RECTANGLE-SECT-5.19.1">public String toString()</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
A string representation of the <tt CLASS=literal>Rectangle</tt> 
object. 

<p>
<DT CLASS=varlistentry>Overrides<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>Object.toString()</tt> </DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="JAWT-CH-19-REF-RECTANGLE-SECT-5.20">translate</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="JAWT-CH-19-REF-RECTANGLE-SECT-5.20.1">public void translate (int deltax, int deltay)</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters <br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><I CLASS=emphasis>deltax</I><br>
<DD>

<P CLASS=para>
Amount to move <tt CLASS=literal>Rectangle</tt> 
horizontally. 

<p>
<DT CLASS=varlistentry><I CLASS=emphasis>deltay</I><br>
<DD>

<P CLASS=para>
Amount to move <tt CLASS=literal>Rectangle</tt> 
vertically. </DL>
<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
Moves the <tt CLASS=literal>Rectangle</tt>'s 
origin to (<tt CLASS=literal>x+deltax</tt>, <tt CLASS=literal>y+deltay</tt>). </DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="JAWT-CH-19-REF-RECTANGLE-SECT-5.21">union</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="JAWT-CH-19-REF-RECTANGLE-SECT-5.21.1">public Rectangle union (Rectangle r)</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><I CLASS=emphasis>r</I><br>
<DD>

<P CLASS=para>
Rectangle to determine 
union with. </DL>
<p>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
The smallest <tt CLASS=literal>Rectangle</tt> containing 
both <tt CLASS=literal>r</tt> and the current <tt CLASS=literal>Rectangle</tt>. 

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
Generates a new <tt CLASS=literal>Rectangle</tt> by 
combining <tt CLASS=literal>r</tt> and the current 
<tt CLASS=literal>Rectangle</tt>. </DL>
</DIV>

</DIV>

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="JAWT-CH-19-REF-RECTANGLE-SECT-6">See Also</A></h2>

<P CLASS=para>
<tt CLASS=literal>Dimension</tt>, <tt CLASS=literal>Object</tt>, 
<tt CLASS=literal>Point</tt>, <tt CLASS=literal>String</tt> 

</DIV>


<DIV CLASS=htmlnav>

<P>
<HR align=left width=515>
<table width=515 border=0 cellpadding=0 cellspacing=0>
<tr>
<td width=172 align=left valign=top><A HREF="ch19_51.htm"><IMG SRC="gifs/txtpreva.gif" ALT="Previous" border=0></A></td>
<td width=171 align=center valign=top><a href="index.htm"><img src='gifs/txthome.gif' border=0 alt='Home'></a></td>
<td width=172 align=right valign=top><A HREF="ch19_53.htm"><IMG SRC="gifs/txtnexta.gif" ALT="Next" border=0></A></td>
</tr>
<tr>
<td width=172 align=left valign=top>PrintJob <img src="gifs/bstar.gif" alt="(New)" border=0></td>
<td width=171 align=center valign=top><a href="index/idx_a.htm"><img src='gifs/index.gif' alt='Book Index' border=0></a></td>
<td width=172 align=right valign=top>ScrollPane <img src="gifs/bstar.gif" alt="(New)" border=0></td>
</tr>
</table>
<hr align=left width=515>

<IMG SRC="gifs/smnavbar.gif" USEMAP="#map" BORDER=0> 
<MAP NAME="map"> 
<AREA SHAPE=RECT COORDS="0,0,108,15" HREF="../javanut/index.htm"
alt="Java in a Nutshell"> 
<AREA SHAPE=RECT COORDS="109,0,200,15" HREF="../langref/index.htm" 
alt="Java Language Reference"> 
<AREA SHAPE=RECT COORDS="203,0,290,15" HREF="../awt/index.htm" 
alt="Java AWT"> 
<AREA SHAPE=RECT COORDS="291,0,419,15" HREF="../fclass/index.htm" 
alt="Java Fundamental Classes"> 
<AREA SHAPE=RECT COORDS="421,0,514,15" HREF="../exp/index.htm" 
alt="Exploring Java"> 
</MAP>
</DIV>

</BODY>
</HTML>
